#include "drv.h"
#include "mid.h"
#include "task.h"



int main(void) 
{
	Drv_Init() ;
	Mid_Init() ; 
	Task_Init() ;
	while(1)
	{
		
		Task_Process() ;
		
	}
}

/* Event used to notify the Host that a hardware failure has occurred in the Controller. 
See bluenrg_lp_events.h.
 *        - 0x00: Generic HW error
 *        - 0x01: Radio state error
 *        - 0x02: Timer overrun error
 *        - 0x03: Internal queue overflow error
 *        - 0x04: Late Radio ISR
 *        - 0x05: TX Error */
void hci_hardware_error_event(uint8_t Hardware_Code)
{
	if (Hardware_Code <= 0x03)
	{
		NVIC_SystemReset();
	}
}


/**
* This event is generated to report firmware error informations.
* FW_Error_Type possible values: 
* Values:
- 0x01: L2CAP recombination failure
- 0x02: GATT unexpected response
- 0x03: GATT unexpected request
After this event with error type (0x01, 0x02, 0x3) it is recommended to disconnect. 
*/
void aci_hal_fw_error_event(uint8_t FW_Error_Type,
			    uint8_t Data_Length,
			    uint8_t Data[])
{
	if (FW_Error_Type <= 0x03)
	{
		uint16_t connHandle;
		
		/* Data field is the connection handle where error has occurred */
		connHandle = LE_TO_HOST_16(Data);
		
		aci_gap_terminate(connHandle, BLE_ERROR_TERMINATED_REMOTE_USER); 
	}
}

/***************************************************************************************/

#ifdef USE_FULL_ASSERT
/*******************************************************************************
* Function Name  : assert_failed
* Description    : Reports the name of the source file and the source line number
*                  where the assert_param error has occurred.
* Input          : - file: pointer to the source file name
*                  - line: assert_param error line source number
* Output         : None
* Return         : None
*******************************************************************************/
void assert_failed(uint8_t* file, uint32_t line)
{
	/* User can add his own implementation to report the file name and line number,
	ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
	
	/* Infinite loop */
	while (1)
	{}
}
#endif

